package test.utils;

import java.io.*;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : example
 * @ Author: XuLeHuang
 * @ Date: 2022/7/26 17:11
 * @ Description:
 */
public class ObjectSerializableUtil {

    public static boolean doWriteObjectBySerializable(String str) {
        try {
            ObjectOutputStream os = new ObjectOutputStream(
                    new FileOutputStream("D:\\资料\\神州信息\\smpv.ts0008.txt"));
            os.writeObject(str);
            os.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return true;
    }
    public static String doGetObjectFromRejectSerializable(String path) {
        String str = "";
        try {
            ObjectInputStream is = new ObjectInputStream(
                    new FileInputStream(path));

            str = (String) is.readObject();
            System.out.println(str);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return str;
    }

}
